(function (name, factory) {

	for (var i in name) {
		if (window[name[i]] == undefined) {
			window[name[i]] = factory[i]();
		} else {
			window[name[i]] = {};
			console.log('命名重复')
		}
	}
	// $('body').on('click', '.gz-action-back', function () {
	// 	var u = navigator.userAgent,
	// 		app = navigator.appVersion;
	// 	var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
	// 	var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	// 	if (isIOS) {
	// 		window.webkit.messageHandlers.iosBack.postMessage(-1);
	// 	} else {
	// 		history.back(-1);
	// 	}
	// });



	(function flexible(window, document) {
		var docEl = document.documentElement
		var dpr = window.devicePixelRatio || 1

		// adjust body font size
		function setBodyFontSize() {
			if (document.body) {
				document.body.style.fontSize = (12 * dpr) + 'px'
			} else {
				document.addEventListener('DOMContentLoaded', setBodyFontSize)
			}
		}
		setBodyFontSize();

		// set 1rem = viewWidth / 10
		function setRemUnit() {
			var rem = docEl.clientWidth / 10
			docEl.style.fontSize = rem + 'px'
		}

		setRemUnit()

		// reset rem unit on page resize
		window.addEventListener('resize', setRemUnit)
		window.addEventListener('pageshow', function (e) {
			if (e.persisted) {
				setRemUnit()
			}
		})

		// detect 0.5px supports
		if (dpr >= 2) {
			var fakeBody = document.createElement('body')
			var testElement = document.createElement('div')
			testElement.style.border = '.5px solid transparent'
			fakeBody.appendChild(testElement)
			docEl.appendChild(fakeBody)
			if (testElement.offsetHeight === 1) {
				docEl.classList.add('hairlines')
			}
			docEl.removeChild(fakeBody)
		}

		var screenHeight;
		if (window.innerHeight) {
			screenHeight = window.innerHeight;
		} else if ((document.body) && (document.body.clientHeight)) {
			screenHeight = document.body.clientHeight;
		}
		$("html,body").height(screenHeight);

		//判断页面是否是在微信浏览器打开
		//对浏览器的UserAgent进行正则匹配，不含有微信独有标识的则为其他浏览器
		// var useragent = navigator.userAgent;
		// if (useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
		//     window.location.href = "wxError.html";//若不是微信浏览器，跳转到温馨error页面
		// }
	}(window, document));
})(['wbComMethod', 'staticConfig'], [
	function () {
		var data = {
			openNewWin: function (config) {
				var url = config.url;
				if (config.params) {
					url += '?' + encodeURIComponent(config.params) + '=' + encodeURIComponent(config.paramid);
					//console.log(url);
				}
				window.location.href = url;
			},
			backWin: function () {
				history.back(-1);
			},
			setLocalStorage: function (obj) {
				if (!window.localStorage) {
					alert("浏览器支持localstorage");
					return false;
				} else {
					var arry = []
					if (localStorage.getItem("line")) arry = JSON.parse(localStorage.getItem("line"));
					arry.unshift(obj);
					localStorage.removeItem('line');
					localStorage.setItem('line', JSON.stringify(arry));
				}
			},
			onUrlParams: function () {
				var str = decodeURIComponent(location.search);
				if (str) {
					var url = str.substr(1),
						arr = url.split('&'),
						len = arr.length,
						i = 0,
						request = {};
					for (; i < len; i++) {
						request[arr[i].split('=')[0]] = arr[i].split('=')[1];
						request[arr[i].split('=')[2]] = arr[i].split('=')[3];
					}
					return request;
				} else {
					return;
				}
			},
			loadMask: {
				show: function () {
					var html = '<div class="mui-loading"> <div class="mui-spinner"> </div> </div>';
					$('body').append(html);
				},
				hide: function () {
					if ($('body .mui-loading').length > 0) $('body .mui-loading').remove();
				}
			},
			showNullInfoMsg: function (msg, img) {
				var html = '<div class="def-img"><img  src="' + img + '"/>' +
					'<p>' + msg + '</p></div>';
				return html;
			}
		};
		//console.log(data);
		return data;
	},
	function () {
		var data = {
			pageUrl: {
				lineSearchDetail: 'view/show-site.html',
				transferSearch: 'view/transfer-search.html',
				transferDetail: 'transfer-detail.html',
			}
		};
		return data;
	}
]);

function historyBack() {
	var u = navigator.userAgent,
		app = navigator.appVersion;
	var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //g
	var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	if (isIOS) {
		window.webkit.messageHandlers.iosBack.postMessage(-1);
	} else {
		history.back(-1);
	}
}